diff options
| author | Adam Soltys <[email protected]> | 2024-08-31 15:23:49 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-08-31 15:23:49 -0700 |
| commit | a89d4ee9b9bf0c15505a58803585f1847731983e (patch) | |
| tree | 46098814beabc79de334898dbc4808aed8d5f329 /src/routes/(app)/[username] | |
| parent | df71664f20312e81134ee90ad561f55d3020ee0a (diff) | |
| download | coinos-ui-a89d4ee9b9bf0c15505a58803585f1847731983e.tar.gz coinos-ui-a89d4ee9b9bf0c15505a58803585f1847731983e.zip | |
typescript
Diffstat (limited to 'src/routes/(app)/[username]')
12 files changed, 31 insertions, 22 deletions
diff --git a/src/routes/(app)/[username]/(profile)/event/[id]/+page.server.ts b/src/routes/(app)/[username]/(profile)/event/[id]/+page.server.ts index 42c568c5..baeab3d7 100644 --- a/src/routes/(app)/[username]/(profile)/event/[id]/+page.server.ts +++ b/src/routes/(app)/[username]/(profile)/event/[id]/+page.server.ts @@ -6,7 +6,7 @@ export async function load({ params: { id } }) { let event = await get(`/event/${id}`); if (!event) error(500, "Event not found"); return { event }; - } catch (e: Error) { + } catch (e: any) { error(500, e.message); } } diff --git a/src/routes/(app)/[username]/address/+page.server.ts b/src/routes/(app)/[username]/address/+page.server.ts index d173594a..2f7841ab 100644 --- a/src/routes/(app)/[username]/address/+page.server.ts +++ b/src/routes/(app)/[username]/address/+page.server.ts @@ -1,9 +1,8 @@ -import { auth, get, post } from "$lib/utils"; +import { auth, post } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; -export async function load({ cookies, params, parent }) { +export async function load({ cookies, parent }) { let user = (await parent()).subject; - let rates = await get("/rates"); let invoice = { type: "bitcoin" }; let { id } = await post(`/invoice`, { invoice, user }, auth(cookies)); redirect(307, `/${user.username}/invoice/${id}`); diff --git a/src/routes/(app)/[username]/generate/+server.ts b/src/routes/(app)/[username]/generate/+server.ts index 3e3a9358..cdfac166 100644 --- a/src/routes/(app)/[username]/generate/+server.ts +++ b/src/routes/(app)/[username]/generate/+server.ts @@ -5,7 +5,7 @@ export async function POST({ cookies, request }) { try { let body = await request.json(); return json(await post(`/user`, body, auth(cookies))); - } catch (e) { + } catch (e: any) { error(500, e.message); } } diff --git a/src/routes/(app)/[username]/items/[id]/+page.server.ts b/src/routes/(app)/[username]/items/[id]/+page.server.ts index 4cfc952c..67cebd93 100644 --- a/src/routes/(app)/[username]/items/[id]/+page.server.ts +++ b/src/routes/(app)/[username]/items/[id]/+page.server.ts @@ -1,7 +1,7 @@ import { fd, auth, get, post } from "$lib/utils"; import { fail, redirect } from "@sveltejs/kit"; -export let load = async ({ cookies, params: { id } }) => { +export let load = async ({ params: { id } }) => { let item = await get(`/items/${id}`); return { item }; }; @@ -11,7 +11,7 @@ export const actions = { let form = await fd(request); try { await post(`/items`, form, auth(cookies)); - } catch (e) { + } catch (e: any) { return fail(400, { message: e.message }); } diff --git a/src/routes/(app)/[username]/items/create/+page.server.ts b/src/routes/(app)/[username]/items/create/+page.server.ts index 8cb48399..2e006a3e 100644 --- a/src/routes/(app)/[username]/items/create/+page.server.ts +++ b/src/routes/(app)/[username]/items/create/+page.server.ts @@ -1,12 +1,12 @@ import { fail, redirect } from "@sveltejs/kit"; -import { fd, auth, get, post } from "$lib/utils"; +import { fd, auth, post } from "$lib/utils"; export const actions = { default: async ({ cookies, request, url }) => { let form = await fd(request); try { await post("/items", form, auth(cookies)); - } catch (e) { + } catch (e: any) { return fail(400, { message: e.message }); } diff --git a/src/routes/(app)/[username]/messages/+page.server.ts b/src/routes/(app)/[username]/messages/+page.server.ts index 33d9ccaa..94659621 100644 --- a/src/routes/(app)/[username]/messages/+page.server.ts +++ b/src/routes/(app)/[username]/messages/+page.server.ts @@ -1,7 +1,16 @@ -import { auth, get } from "$lib/utils"; +import { get } from "$lib/utils"; import { redirect } from "@sveltejs/kit"; -export async function load({ cookies, params, parent, url }) { +interface Message { + created_at: number; +} + +interface Note { + created_at: number; + seen: number; +} + +export async function load({ params, parent, }) { let { user } = await parent(); if (user.username !== params.username) redirect(307, `/${params.username}`); let { since = 0 } = params; @@ -13,7 +22,7 @@ export async function load({ cookies, params, parent, url }) { let { pubkey } = user; try { messages = await get(`/${pubkey}/${since}/messages`); - messages = messages.sort((a, b) => b.created_at - a.created_at); + messages = messages.sort((a: Message, b: Message) => b.created_at - a.created_at); } catch (e) { console.log(`failed to fetch nostr messages`, e); } @@ -24,7 +33,7 @@ export async function load({ cookies, params, parent, url }) { console.log(`failed to fetch nostr notes for ${pubkey}`, e); } - notes.map((e) => { + notes.map((e: Note) => { e.seen = e.created_at; }); } diff --git a/src/routes/(app)/[username]/messages/[recipient]/+page.server.ts b/src/routes/(app)/[username]/messages/[recipient]/+page.server.ts index 6936a06b..6be9f6ec 100644 --- a/src/routes/(app)/[username]/messages/[recipient]/+page.server.ts +++ b/src/routes/(app)/[username]/messages/[recipient]/+page.server.ts @@ -1,10 +1,11 @@ import { get } from "$lib/utils"; +import type { Message } from "$lib/types"; -export async function load({ params, parent, url }) { +export async function load({ params, parent }) { let { user } = await parent(); let { since = 0 } = params; - let messages = []; + let messages: Message[] = []; let recipient = await get(`/users/${params.recipient}`); try { @@ -12,7 +13,7 @@ export async function load({ params, parent, url }) { messages = messages .filter( - (m) => m.recipient?.id === recipient.id || m.author?.id === recipient.id + (m: Message) => m.recipient?.id === recipient.id || m.author?.id === recipient.id ) .sort((a, b) => a.created_at - b.created_at); } catch (e) { diff --git a/src/routes/(app)/[username]/payments/[...page]/+page.server.ts b/src/routes/(app)/[username]/payments/[...page]/+page.server.ts index 4a539e43..070349f8 100644 --- a/src/routes/(app)/[username]/payments/[...page]/+page.server.ts +++ b/src/routes/(app)/[username]/payments/[...page]/+page.server.ts @@ -2,7 +2,7 @@ import { get, auth } from "$lib/utils"; let limit = 25; -export async function load({ cookies, depends, params, request }) { +export async function load({ cookies, depends, params }) { depends("app:payments"); let parts = params.page.split("/"); diff --git a/src/routes/(app)/[username]/receive/[...param]/+page.server.ts b/src/routes/(app)/[username]/receive/[...param]/+page.server.ts index 953954e9..502678a9 100644 --- a/src/routes/(app)/[username]/receive/[...param]/+page.server.ts +++ b/src/routes/(app)/[username]/receive/[...param]/+page.server.ts @@ -1,11 +1,11 @@ import { redirect } from "@sveltejs/kit"; import { auth, post } from "$lib/utils"; -import invoice from "$lib/invoice"; +import type { Invoice } from "$lib/types"; export let load = async ({ cookies, parent }) => { let {subject, user, rates } = await parent(); - let invoice = { + let invoice: Invoice = { type: "lightning", rate: rates[user?.currency || subject?.currency], }; diff --git a/src/routes/(app)/[username]/settings/[...tab]/+page.server.ts b/src/routes/(app)/[username]/settings/[...tab]/+page.server.ts index 5ff691f0..42639b38 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/+page.server.ts +++ b/src/routes/(app)/[username]/settings/[...tab]/+page.server.ts @@ -23,7 +23,7 @@ export const actions = { try { ({ user } = await post(`/user`, user, auth(cookies))); - } catch (e) { + } catch (e: any) { return fail(400, { message: e.message }); } diff --git a/src/routes/(app)/[username]/shopify.js/+server.ts b/src/routes/(app)/[username]/shopify.js/+server.ts index c93ac729..43a2ef2d 100644 --- a/src/routes/(app)/[username]/shopify.js/+server.ts +++ b/src/routes/(app)/[username]/shopify.js/+server.ts @@ -1,4 +1,4 @@ -export async function GET({ cookies, params, url }) { +export async function GET({ params, url }) { let { username } = params; let js = ` diff --git a/src/routes/(app)/[username]/verify/[code]/+page.server.ts b/src/routes/(app)/[username]/verify/[code]/+page.server.ts index 19453d9d..fec1a85c 100644 --- a/src/routes/(app)/[username]/verify/[code]/+page.server.ts +++ b/src/routes/(app)/[username]/verify/[code]/+page.server.ts @@ -1,5 +1,5 @@ import { get } from "$lib/utils"; -import { error, redirect } from "@sveltejs/kit"; +import { redirect } from "@sveltejs/kit"; export let load = async ({ params: { code } }) => { let user; |
